package com.jinxiangyang.controller;

import com.jinxiangyang.domain.vo.*;
import com.jinxiangyang.service.ChartsService;
import com.jinxiangyang.utils.result.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/charts")
@Api(tags = "图表的接口")
public class ChartsController {

    @Autowired
    ChartsService chartsService;

    @GetMapping("userTypePercent")
    @ApiOperation("获取用户类型占比")
    public AjaxResult userTypePercent(){
        List<UserTypeAmountVo> userTypeAmountVos = chartsService.getUserTypePercent();
        return AjaxResult.success(userTypeAmountVos);
    }

    @GetMapping("userMap")
    @ApiOperation(value = "获取用户分布")
    public AjaxResult userMap(){
        List<UserMapVo> userMapVoList = chartsService.getUserMap();
        return AjaxResult.success(userMapVoList);
    }

    @GetMapping("courseTypePercent")
    @ApiOperation(value = "获取课程类型占比")
    public AjaxResult courseTypePercent(){
        List<CourseTypeAccountVo> courseTypeAccountVoList = chartsService.getCourseTypePercent();
        return AjaxResult.success(courseTypeAccountVoList);
    }

    @GetMapping("courseSale")
    @ApiOperation(value = "获取课程销量")
    public AjaxResult courseSale(){
        int[] courseSaleVoList = chartsService.getCourseSale();
        return AjaxResult.success(courseSaleVoList);
    }

    @GetMapping("courseSales")
    @ApiOperation(value = "获取课程销售额")
    public AjaxResult courseSales(){
        double[] courseSales = chartsService.getCourseSales();
        return AjaxResult.success(courseSales);
    }

}
